<?php
 
use app\services\models\Agency;

function hideMiddle($val){
    if($val == '') return '';
    return substr_replace($val, '****',3, 4);
}

function hideMobile($val){
    if($val == '') return '';
    return substr_replace($val, '****',3, 4);
}


function hideIdNo($val){
    if($val == '') return '';
    return substr_replace($val, '********',3, 8);
}

function isAdmin(){
    $user_auth  = session('user_auth');
    if($user_auth['uid'] != 1){
        return false;
    }
    return true;
}



function getAgencyId(){
    return session('user_auth')['agency_id'];
}



/**
 * 代理
 *
 * @param [type] $agencyId
 * @return void
 */
function getAgencyInfo($agencyId){
    if($agencyId == null || $agencyId == 0){
        return '';
    }else{
        return (Agency::find($agencyId)['name']);
    }
}
